# Maintainer:
pkgname=pure-data
pkgver=0.54.1
_pkgver=0.54-1
_icon=9e4f117ade0bc1da951981128998ad82fff83b0c
pkgrel=0
pkgdesc="Pure Data real-time music and multimedia environment"
url="https://puredata.info"
arch="aarch64 x86_64"
license="BSD-3-Clause"
makedepends="
	alsa-lib-dev
	autoconf
	automake
	fftw-dev
	jack-dev
	libtool
	portaudio-dev
	portmidi-dev
	tk-dev
	"
subpackages="$pkgname-doc $pkgname-libs $pkgname-dev"
source="https://msp.puredata.info/Software/pd-$_pkgver.src.tar.gz
	pd-$_icon.svg::https://raw.githubusercontent.com/pure-data/pd-icon/$_icon/masters/icon.svg
	system-portmidi.patch
	implicit.patch
	"
builddir="$srcdir/pd-$_pkgver"
options="!check" # no tests

prepare() {
	default_prepare

	NOCONFIGURE=1 ./autogen.sh
}

build() {
	CFLAGS="$CFLAGS -O2 -flto=auto" \
	EXTERNAL_LDFLAGS="$LDFLAGS" \
	./configure \
		--prefix=/usr \
		--host=$CHOST \
		--build=$CBUILD \
		--enable-fftw \
		--enable-alsa \
		--enable-jack \
		--enable-libpd \
		--enable-libpd-utils \
		--enable-libpd-instance \
		--enable-libpd-extras \
		--disable-oss \
		--disable-static \
		--without-local-portaudio \
		--without-local-portmidi
	make
}

package() {
	make DESTDIR="$pkgdir" install

	ln -sfv ../../../bin/pd "$pkgdir"/usr/lib/pd/bin/pd

	install -Dm644 "$srcdir"/pd-$_icon.svg \
		"$pkgdir"/usr/share/icons/hicolor/scalable/apps/pd.svg

	rm -r "$pkgdir"/usr/share/pixmaps
}

doc() {
	default_doc

	amove usr/lib/pd/doc
}

sha512sums="
619a4bb9ddb13fdc278e868c98c8715e1251936f34d5d43da275cf4c9fdd18aa4a140c7def7e6201b6aa0ea3193afc65afe85efd44139a4534b332187b675a55  pd-0.54-1.src.tar.gz
8d8b274e159bd4cc6a83d5d9d5019b106a74fa61943b36e2a56336b9c3c2c1b1092ce7f79f5264eb69ca43a9360404b800df338b2ad738ca3c237a8ae3c9c41d  pd-9e4f117ade0bc1da951981128998ad82fff83b0c.svg
8a346e9ecfe31de92639ca546bbdf7f9c55d3123bf71dcaeea77b55fdf0b9ec5850b23c2b25396b9b7bec46c0b0bdcae9eaf4c5d35d0425a4ae5f592401ceccf  system-portmidi.patch
ac563547cc677cda793badb7994548867e7f55c1a59167de7e92f871f711b6f1fa188e9fa30413a27e8d76adbd01e7a795a577bfc3599f91a60b055ea25d21a0  implicit.patch
"
